﻿@helper DateTimeString(DateTime d, string format = "yyyy-MM-dd HH:mm",string formatdateonly="yyyy-MM-dd")
    {
        if (d == DateTime.MinValue || d == DateTime.MaxValue)
        {
    @string.Empty;
        }
        else if(d.Date==d)
        {
            @d.ToString(formatdateonly);
        }
        else
        {
            @d.ToString(format);
        }
}
@helper Shadowbox(Func<dynamic, object> template)
    {
    <div class="shadowBox">
        <div class="boxBody">
            @template(null)
        </div>
        <span class="shadowLeft"></span><span class="shadowRight"></span>
    </div>
}
@helper SubmitButton(string text, string id = "")
    {
        id = string.IsNullOrWhiteSpace(id) ? "submit" : id;
    <input type="submit" id="@(id)" value="@(text)" name="@(id)" />
        if (!CurrentPage.PageData.ContainsKey("IsSubmitButtonScriptRegister"))
        {
            CurrentPage.PageData.Add("IsSubmitButtonScriptRegister", true);
    <script type="text/javascript">
        $(function () {
            $('input:submit').button();
        });
    </script>
        }
}
@helper TryRenderRequiredTag(bool IsRequired)
    {
        if (IsRequired)
        {
    <span class="required-label">*</span>
        }
}
@helper GetAge(DateTime birthday)
    {
        var a = DateTime.Today.Year - birthday.Year;
        if (birthday.Date.AddYears(a) > DateTime.Today) { a--; }
    <span>@a</span>
}
@helper GetAgeRaw(DateTime birthday)
    {
        if (birthday > DateTime.MinValue)
        {
            var a = DateTime.Today.Year - birthday.Year;
            if (birthday.Date.AddYears(a) > DateTime.Today) { a--; }
            @a
        }
        else
        {
            var b = string.Empty;
            @b;
        }
}
@helper RadioList(string name, string[] values, string[] titles, int checkidx, bool SpanOrDiv)
    {
        var sod = SpanOrDiv ? "<span>" : "<div>";
        var sod2 = SpanOrDiv ? "</span>" : "</div>";
        for (int i = 0; i < values.Length; i++)
        {
            var id = name + "_v_" + i.ToString();
            if (SpanOrDiv)
            {
    <span>
        <input type="radio" name="@(name)" value="@(values[i])" id="@id" />
        <label for="@id">@titles[i]</label>
    </span>
            }
            else
            {
    <div>
        <input type="radio" name="@(name)" value="@(values[i])" id="@id" />
        <label for="@id">@titles[i]</label>
    </div>
            }
        }
}